/**
 * 平铺树形结构
 * @param {*} tree
 * @param {*} children 子级字段
 * @returns
 */
function treeToArray(tree, childrenName = "children") {
    let queen = [];
    const out = [];
    queen = queen.concat(tree);
    while (queen.length) {
        const first = queen.shift();
        if (first && first[childrenName]) {
            queen = queen.concat(first[childrenName]);
            delete first[childrenName];
        }
        if (first) {
            out.push(first);
        }
    }
    return out;
}

export { treeToArray as default };
